package com.suifeng.card.controller;

import com.alibaba.fastjson.JSON;
import com.google.common.base.Preconditions;
import com.suifeng.card.api.common.Result;
import com.suifeng.card.entity.Social;
import com.suifeng.card.entity.User;
import com.suifeng.card.service.SocialService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (Social)表控制层
 *
 */
@RestController
@Slf4j
public class SocialController {
    /**
     * 服务对象
     */
    @Resource
    private SocialService socialService;


    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<Social> queryById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.socialService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param social 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<Social> add(Social social) {
        return ResponseEntity.ok(this.socialService.insert(social));
    }

    /**
     * 编辑数据
     *
     * @param social 实体
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<Social> edit(Social social) {
        return ResponseEntity.ok(this.socialService.update(social));
    }




}

